package com.artmofang.controller;
import com.artmofang.common.utils.JSONResult;
import com.artmofang.pojo.ArtOaUser;
import com.artmofang.service.ErpUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("erp_user")
public class ErpUserController {
    @Autowired
    private ErpUserService eprUserService;

    @ApiOperation(value = "通过账号密码匹配查询用户信息", notes = "通过账号密码匹配查询用户信息", httpMethod = "POST")
    @PostMapping("/queryUserInfo")
    public Object queryUserInfo(@RequestBody Map<String,String> param) {
        List<ArtOaUser> list = eprUserService.queryUserInfo(param.get("username"),param.get("password"));

        if(list.size() == 0){
            return JSONResult.errorMsg("用户账号或密码不正确");
        }

        return JSONResult.ok(list);
    }
}
